import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
//  setup语法糖写法给组件添加name属性
import vueSetupExtend from 'vite-plugin-vue-setup-extend';

import components from 'unplugin-vue-components/vite';
import autoImport from 'unplugin-auto-import/vite';
import { VarletImportResolver } from '@varlet/import-resolver';

import { resolve } from 'path';

// https://vitejs.dev/config/
export default defineConfig({
  define: { 'process.env': {} },
  base:'./',
  plugins: [
    vue(),
    components({
      resolvers: [VarletImportResolver()],
    }),
    autoImport({
      resolvers: [VarletImportResolver({ autoImport: true })],
    }),
    vueSetupExtend(),
    
  ],
  build: {
    outDir: resolve(__dirname, '../electron/dist'),
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:7001/api', // 目标服务器地址
        changeOrigin: true, // 是否改变源地址
        rewrite: (path) => path.replace(/^\/api/, '/api'), // 重写路径
      },
    },
  },
});
